﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ExcelSystem.Migrations
{
    /// <inheritdoc />
    public partial class Created2 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Material_Orders_OrderID",
                table: "Material");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Material",
                table: "Material");

            migrationBuilder.RenameTable(
                name: "Material",
                newName: "Materials");

            migrationBuilder.RenameIndex(
                name: "IX_Material_OrderID",
                table: "Materials",
                newName: "IX_Materials_OrderID");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Materials",
                table: "Materials",
                column: "ID");

            migrationBuilder.CreateTable(
                name: "BOMs",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    MaterialNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ChildMaterialNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ChannelSteel = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ChannelSteelID = table.Column<int>(type: "int", nullable: false),
                    Weight = table.Column<double>(type: "float", nullable: true),
                    RibbedPlateNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    RibbedPlateType = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    RibbedPlateNumber = table.Column<double>(type: "float", nullable: true),
                    RibbedPlateWeight = table.Column<double>(type: "float", nullable: true),
                    RopeHeadNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    RopeHeadType = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    RopeHeadNumber = table.Column<double>(type: "float", nullable: true),
                    RopeHeadWeight = table.Column<double>(type: "float", nullable: true),
                    Counterweight = table.Column<double>(type: "float", nullable: true),
                    RawMaterials = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CarRoofQheelDiameter = table.Column<double>(type: "float", nullable: true),
                    WireRopeHole = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    HostPosition = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MakeDirection = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Direction = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ChildPar = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Par = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Accessories = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AccessoriesSize = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AccessoriesNumner = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AccessoriesHandle = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AccessoriesRemark = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BOMs", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Filters",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Company = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Filters", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Formulas",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ReflectionProperty = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Property = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsBase = table.Column<bool>(type: "bit", nullable: false),
                    FormulaType = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Formulas", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "NSMaterials",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Category = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Type = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LegThickness = table.Column<double>(type: "float", nullable: true),
                    WaistThickness = table.Column<double>(type: "float", nullable: true),
                    Length = table.Column<double>(type: "float", nullable: true),
                    UnitWeight = table.Column<double>(type: "float", nullable: true),
                    Width = table.Column<double>(type: "float", nullable: true),
                    Height = table.Column<double>(type: "float", nullable: true),
                    TheoreticalWeight = table.Column<double>(type: "float", nullable: true),
                    ActualWeight = table.Column<double>(type: "float", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NSMaterials", x => x.ID);
                });

            migrationBuilder.AddForeignKey(
                name: "FK_Materials_Orders_OrderID",
                table: "Materials",
                column: "OrderID",
                principalTable: "Orders",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Materials_Orders_OrderID",
                table: "Materials");

            migrationBuilder.DropTable(
                name: "BOMs");

            migrationBuilder.DropTable(
                name: "Filters");

            migrationBuilder.DropTable(
                name: "Formulas");

            migrationBuilder.DropTable(
                name: "NSMaterials");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Materials",
                table: "Materials");

            migrationBuilder.RenameTable(
                name: "Materials",
                newName: "Material");

            migrationBuilder.RenameIndex(
                name: "IX_Materials_OrderID",
                table: "Material",
                newName: "IX_Material_OrderID");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Material",
                table: "Material",
                column: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_Material_Orders_OrderID",
                table: "Material",
                column: "OrderID",
                principalTable: "Orders",
                principalColumn: "ID");
        }
    }
}
